﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using Microsoft.Windows.Controls;

namespace FrontEnd_step2
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{
        ModdbFrontEnd frontEnd;
        public Window1()
		{
            this.InitializeComponent();

            frontEnd = new ModdbFrontEnd();
            DataSet myData = new DataSet();
            DataTable table = new DataTable("testingTesting");
            table.Columns.Add(new DataColumn("ID", typeof(int)));
            table.Columns.Add(new DataColumn("text", typeof(string)));
            DataRow row = table.NewRow();
            row[0] = 1;
            row[1] = "hejhopp";
            table.Rows.Add(row);
            myData.Tables.Add(table);
            this.DataContext = myData.Tables["testingTesting"];
			
			// Insert code required on object creation below this point.
		}

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (UserName.Text.Equals("alex") && Password.Password.Equals("abc123"))
            {
                LoginLayer.Visibility = Visibility.Collapsed;
                Layer2.Visibility = Visibility.Visible;
                LogoutMenuItem.IsEnabled = true;
            }
        }

        private void ListBox_Loaded(object sender, EventArgs e)
        {
           
        }

        private void Layer2_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue.Equals(true) && ((Canvas)sender).Visibility.Equals(Visibility.Visible))
            {
                Moddb08_WCF.Tables tables = frontEnd.GetAllTables();
                foreach (Moddb08_WCF.Table table in tables)
                {
                    TablesListBox.Items.Add(table.Name);
                }
            }
        }

        private void SelectTable_Click(object sender, RoutedEventArgs e)
        {
            
        }

	}
}